package cz.semjob.learning.data;

import java.util.ArrayList;
import java.util.List;

import cz.semjob.learning.data.attribute.AInstanceAttribute;
import cz.semjob.learning.instances.LabeledTextInstance;

public class DataSet implements IDataSet {

	private String name;

	private List<AInstanceAttribute> attributesList;

	private List<LabeledTextInstance> positiveInstances;
	private List<LabeledTextInstance> negativeInstances;

	public DataSet(String name) {
		super();
		this.name = name;
		this.positiveInstances = new ArrayList<LabeledTextInstance>();
		this.negativeInstances = new ArrayList<LabeledTextInstance>();
	}

	public void addPositiveInstances(List<LabeledTextInstance> instances) {
		positiveInstances.addAll(instances);
	}

	public void addNegativeInstances(List<LabeledTextInstance> instances) {
		negativeInstances.addAll(instances);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<AInstanceAttribute> getAttributesList() {
		return attributesList;
	}

	public void setAttributesList(List<AInstanceAttribute> attributesList) {
		this.attributesList = attributesList;
	}

	public List<LabeledTextInstance> getPositiveInstances() {
		return positiveInstances;
	}

	public List<LabeledTextInstance> getNegativeInstances() {
		return negativeInstances;
	}

	public int getPositiveInstancesSize() {
		return this.positiveInstances.size();
	}

	public int getNegativeInstancesSize() {
		return this.negativeInstances.size();
	}

	public List<String> getAttributesNamesList() {
		List<String> attributesNames = new ArrayList<String>();
		for (AInstanceAttribute attribute : attributesList) {
			attributesNames.add(attribute.getName());
		}
		return attributesNames;
	}

	public AInstanceAttribute getAttributeForName(String name) {
		for (AInstanceAttribute attribute : attributesList) {
			if (attribute.getName().equals(name)) {
				return attribute;
			}
		}
		return null;
	}

}
